package com.springboot.demo.design.pattern.builder;

import com.springboot.demo.design.pattern.Connection;

/**
 * 建造者
 *
 * @author supu
 * @date 2019-07-04 16:26
 **/
public class ConnectionBuilder {
    private String host;
    private Integer port;

    private ConnectionBuilder() {
    }

    public static ConnectionBuilder builder() {
        return new ConnectionBuilder();
    }

    public ConnectionBuilder host(String host) {
        this.host = host;
        return this;
    }

    public ConnectionBuilder port(Integer port) {
        this.port = port;
        return this;
    }

    public Connection build() {
        return new Connection(this.host, this.port);
    }
}
